package com.example.testapp.activity.activity.read;

import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;

import com.example.testapp.R;

/**
 * Created by l on 2016/7/28.
 */
public class FabBtnActivity extends AppCompatActivity {

    private boolean mIsCheck;
    private static int[] STATE_CHECKED = new int[]{android.R.attr.state_checked};
    private static int[] STATE_UNCHECKED = new int[]{};
    private ImageView mImageView;
    private Drawable  mDrawable;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_fab_anim);
        mImageView = (ImageView) findViewById(R.id.image);
        mDrawable = getResources().getDrawable(R.drawable.fab_anim);
        mImageView.setImageDrawable(mDrawable);
        mImageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mIsCheck){
                    mImageView.setImageState(STATE_UNCHECKED, true);
                    mIsCheck = false;
                }else {
                    mImageView.setImageState(STATE_CHECKED, true);
                    mIsCheck = true;
                }
            }
        });
    }
}
